<template>
  <!-- :data="tableData" 表格的数据源--数据来源 -->
  <el-table :data="tableData" style="width: 100%">
    <!-- el-table-column 列表模板  每一列的内容-->

    <!-- 第一列的模板， 默认每一列的内容都是文本 -->
    <!-- prop="date" 表示数组中元素的date属性 就是这列内容 -->
    <!-- label="日期"  表头 -->
    <!-- <el-table-column prop="date" label="日期" width="180" /> -->

    <el-table-column label="日期" width="180">
      <template #default="scope">
        <div style="display: flex; align-items: center">
          <el-icon><timer /></el-icon>
          <!--  scope 插槽反向传递过来的数据---插槽作用域-->
          <!-- scope.row 每一行对应的数组中元素 -->
          <!-- {{ scope.row }} -->
          <!-- <span style="margin-left: 10px">{{ scope.row.date }}</span> -->
          <button>{{ scope.row.date }}</button>
          <!-- <img :src="scope.row.imgUrl" alt="" /> -->
        </div>
      </template>
    </el-table-column>

    <el-table-column prop="name" label="姓名" width="180" />
    <el-table-column prop="address" label="地址" />

    <el-table-column label="操作">
      <template #default="scope">
        <el-button size="small" @click="handleEdit(scope.$index, scope.row)">
          编辑
        </el-button>
        <el-button
          size="small"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)"
        >
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script lang="ts" setup>
interface ITableItem {
  date: string
  name: string
  address: string
}
const tableData: Array<ITableItem> = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
function handleEdit(index: number, row: ITableItem) {
  console.log(index)
  console.log(row)
}
function handleDelete(index, row) {}
</script>
